package biz.model;

import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "bbs_record")
public class BbsRecord implements Serializable {

	private static final long serialVersionUID = 1L;
	private String id;
	private Timestamp opptime;
	private String operatetype;
	private String operatorid;
	private BbsUser operator;
	private String postid;
	private BbsPost post;
	private String publisher;
	private String publisherid;
	private String postmessage;
	private String relationtitle;
	
	@Id
	@GeneratedValue(generator = "pk")
	@GenericGenerator(name = "pk", strategy = "uuid.hex")
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}	
	public Timestamp getOpptime() {
		return opptime;
	}

	public void setOpptime(Timestamp opptime) {
		this.opptime = opptime;
	}

	public String getOperatetype() {
		return operatetype;
	}

	public void setOperatetype(String operatetype) {
		this.operatetype = operatetype;
	}
	
	public String getOperatorid() {
		return operatorid;
	}

	public void setOperatorid(String operatorid) {
		this.operatorid = operatorid;
	}

	public String getPostid() {
		return postid;
	}

	public void setPostid(String postid) {
		this.postid = postid;
	}

	@Transient
	public BbsUser getOperator() {
		return operator;
	}

	public void setOperator(BbsUser operator) {
		this.operator = operator;
	}
	
	@Transient
	public BbsPost getPost() {
		return post;
	}

	public void setPost(BbsPost post) {
		this.post = post;
	}

	public String getPublisher() {
		return publisher;
	}

	public void setPublisher(String publisher) {
		this.publisher = publisher;
	}

	public String getPostmessage() {
		return postmessage;
	}

	public void setPostmessage(String postmessage) {
		this.postmessage = postmessage;
	}

	public String getRelationtitle() {
		return relationtitle;
	}

	public void setRelationtitle(String relationtitle) {
		this.relationtitle = relationtitle;
	}

	public String getPublisherid() {
		return publisherid;
	}

	public void setPublisherid(String publisherid) {
		this.publisherid = publisherid;
	}

	public int hashCode()
	{
		return new HashCodeBuilder().append(getId()).toHashCode();
	}

	public String toString()
	{
		return new ToStringBuilder(this).append("id", getId()).toString();
	}

	public boolean equals(Object other)
	{
		if (this == other)
		{
			return true;
		}
		if (!(other instanceof BbsRecord))
		{
			return false;
		}
		BbsRecord castOther = (BbsRecord) other;
		return new EqualsBuilder().append(this.getId(), castOther.getId()).isEquals();
	}

}
